package com.jlpay.openapi.demo.trans.c2b;

import com.jlpay.open.jlpay.sdk.java.model.trans.c2b.request.QrcodePayRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.c2b.response.QrcodePayResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class QrcodePayService {
    private static final Logger LOGGER = LoggerFactory.getLogger(QrcodePayService.class);

    public static void main(String[] args) {
        QrcodePayRequest qrcodePayRequest = buildQrcodePayRequest();
        QrcodePayResponse qrcodePayResponse = JlpayOpenApiService.openMerchService()
                .post(qrcodePayRequest, QrcodePayResponse.class);
        LOGGER.info("扫码支付(C2B)下单响应:{}", JsonUtils.toString(qrcodePayResponse));
    }

    private static QrcodePayRequest buildQrcodePayRequest() {
        QrcodePayRequest qrcodePayRequest = new QrcodePayRequest();

        qrcodePayRequest.setMchId("849584358120018");
        qrcodePayRequest.setTermNo("60131234");
        qrcodePayRequest.setPayType("wxpay");
        qrcodePayRequest.setOutTradeNo("ld201911023465530");
        qrcodePayRequest.setPaymentValidTime("10");
        qrcodePayRequest.setBody("充值中心-会员充值");
        qrcodePayRequest.setAttach("商城—-易拉宝10个打印纸20箱");
        qrcodePayRequest.setTotalFee("1");
        qrcodePayRequest.setLimitPay("no_credit");
        qrcodePayRequest.setIsHirePurchase("1");
        qrcodePayRequest.setHirePurchaseNum("3");
        qrcodePayRequest.setHirePurchaseSellerPercent("0");
        qrcodePayRequest.setRemark("该订单物流请走顺丰快递");
        qrcodePayRequest.setNotifyUrl("www.baidu.com");
        qrcodePayRequest.setOpUserId("001");
        qrcodePayRequest.setOpShopId("GD_SZ_001");
        qrcodePayRequest.setDeviceInfo("N50007A8890");
        qrcodePayRequest.setMchCreateIp("123.12.12.123");
        qrcodePayRequest.setLongitude("116.078631");
        qrcodePayRequest.setLatitude("39.71274");
        qrcodePayRequest.setSubAppid("wxid_129752pfasf1671");
        qrcodePayRequest.setGoodsTag("sz001");

        return qrcodePayRequest;
    }
}
